/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.dswII.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itsc.dswII.model.Interes;

/**
 *
 * @author Lenovo-user
 */
@Stateless
public class InteresDao extends AbstractDao<Interes> implements InteresDaoLocal {
    @PersistenceContext(unitName = "EmploymentYuri2JEE-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public InteresDao() {
        super(Interes.class);
    }

    @Override
    public boolean findDuplicity(Interes interes) {
        Query q = em.createNamedQuery("Interes.findDuplicity");// Falta acomodar los parametros del query
        q.setParameter("id", interes.getId());
        q.setParameter("categoria", interes.getCatigoria());
        q.setParameter("descripcion",interes.getDescripcion());
        return !q.getResultList().isEmpty();
    }
    public List<Interes> findByInteres(Interes interes) {
       Query q = em.createNamedQuery("Interes.findByCatigoria");
        q.setParameter("catigoria", interes.getCatigoria());
        return q.getResultList();
    }
}
